package andrei.mower2.business;

import andrei.mower2.business.Mower.Direction;


public final class Position {

	public final int x, y;
	
	public Position(int x, int y) {
		this.x = x;
		this.y = y;
	}
	
	public Position advance(Direction direction) {
		return new Position(x + direction.xAdvancement, y + direction.yAdvancement);
	}
	
	@Override
	public int hashCode() {
		long bits = java.lang.Double.doubleToLongBits(x);
        bits ^= java.lang.Double.doubleToLongBits(y) * 31;
        return (((int) bits) ^ ((int) (bits >> 32)));
	}
	
	@Override
	public boolean equals(Object other) {
		if(other==null || !(other instanceof Position)) {
			return false;
		}
		Position otherLawnPosition = (Position)other;
		return x == otherLawnPosition.x && y == otherLawnPosition.y;
	}
}
